//
//  ChildrenStoryInterfaceCell.m
//  HappyBaby
//
//  Created by 华哥 on 15/11/25.
//  Copyright © 2015年 华哥. All rights reserved.
//

#import "ChildrenStoryInterfaceCell.h"
#import "UIImageView+WebCache.h"
#import "Define.h"

@interface ChildrenStoryInterfaceCell ()
@property (nonatomic, strong) UIImageView *imageView;
@property (nonatomic, strong) UILabel *nameLabel;
@property (nonatomic, strong) UILabel *countLabel;
@property (nonatomic, strong) UILabel *fileSizeLabel;
//@property (weak, nonatomic) IBOutlet UIImageView *imageView;
//@property (weak, nonatomic) IBOutlet UILabel *nameLabel;
//@property (weak, nonatomic) IBOutlet UILabel *countLabel;

@end


@implementation ChildrenStoryInterfaceCell

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self)
    {
        float scaleX = kScreenWidth / 375;
        float scaleY = kScreenHeight / 667;
        self.backgroundColor = [UIColor brownColor];
        
//        最上面的ImageView
        self.imageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, frame.size.width, frame.size.width * 3 / 5)];
        [self.contentView addSubview:_imageView];

//        nameLabel
        self.nameLabel = [[UILabel alloc]initWithFrame:CGRectMake(5 * kScreenWidth / 375, self.imageView.frame.size.height, frame.size.width * 3 / 5, frame.size.width / 5)];
        self.nameLabel.font = [UIFont systemFontOfSize:12 * scaleY weight:0.5];
        [self.contentView addSubview:_nameLabel];
        
        //        收听人数Label;
        self.countLabel = [[UILabel alloc]initWithFrame:CGRectMake(self.width - 30 * scaleX, self.imageView.frame.size.height + 3 * scaleY, 50 * kScreenWidth / 375, 15 * scaleY)];
        self.countLabel.font = [UIFont systemFontOfSize:10 * scaleY weight:0.5];
        
        [self.contentView addSubview:_countLabel];
        
//        小的图标
        UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(self.countLabel.x - 15 * scaleX, self.countLabel.y, 15 * scaleY, frame.size.width / 5)];
        imageView.image = [UIImage imageNamed:@"iconfont-dajiazaiting"];
        [self.contentView addSubview:imageView];
        
         self.contentView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
    }
    return self;
}

- (void)setModel:(ChildrenStoryInterface *)model
{
    _model = model;
    [self.imageView sd_setImageWithURL:[NSURL URLWithString:model.pic]];
    self.nameLabel.text = model.name;
    self.countLabel.text = [NSString stringWithFormat:@"%d万",(int)model.playcnt / 10000];
}















@end
